package com.siashan.unipay4j.wx;

import com.siashan.unipay4j.core.Configuration;
import com.siashan.unipay4j.core.util.StrUtil;
import com.siashan.unipay4j.wx.sdk.WXPayConstants;
import lombok.extern.slf4j.Slf4j;

/**
 * 微信支付配置文件
 *
 *
 * @author siashan
 * @since v1.0.1
 */
@Slf4j
public class WxConfiguration {
    private static Configuration configuration = Configuration.getInstance();

    /**
     * 获取开发者第三方用户唯一凭证
     *
     * @return 第三方用户唯一凭证
     */
    public static String getAppId() {
        return configuration.getProperty("siashan.unipay4j.wx.config.appId");
    }


    /**
     * 获取 小程序appid
     *
     * @return 小程序appid
     */
    public static String getAppletAppId() {
        return configuration.getProperty("siashan.unipay4j.wx.config.appletAppId");
    }


    /**
     * 获取 APP appid
     *
     * @return APP appid
     */
    public static String getAppAppId() {
        return configuration.getProperty("siashan.unipay4j.wx.config.appAppId");
    }


    /**
     * 获取  商户号
     *
     * @return 商户号
     */
    public static String getMchId() {
        return configuration.getProperty("siashan.unipay4j.wx.config.mchId");
    }

    /**
     * 获取  商户号对应的key
     *
     * @return 商户号对应的key
     */
    public static String getKey() {
        return configuration.getProperty("siashan.unipay4j.wx.config.key");
    }

    /**
     * 获取 签名类型
     *
     * <p>默认使用HMACSHA256加密</p>
     * @return 签名类型
     */
    public static String getSignType() {
        String signType = configuration.getProperty("siashan.unipay4j.wx.config.signType");
        return StrUtil.isNotEmpty(signType) ? signType : WXPayConstants.MD5;
    }


    /**
     * 获取 回调地址
     *
     * @return 回调地址
     */
    public static String getNotifyUrl() {
        return configuration.getProperty("siashan.unipay4j.wx.config.notifyUrl");
    }


    /**
     * 获取 是否主动上报
     *
     * @return 是否主动上报
     */
    public static boolean getAutoReport() {
        String autoReport = configuration.getProperty("siashan.unipay4j.wx.config.autoReport");
        return Boolean.valueOf(autoReport == null ? "false" : autoReport);
    }

    /**
     * 获取 证书存放路径
     *
     * @return 证书存放路径
     */
    public static String getCertPath() {
        String certPath = configuration.getProperty("siashan.unipay4j.wx.config.certPath");
        return certPath;
    }

    /**
     * 获取 支付接口版本号
     *
     * @return 支付接口版本号
     */
    public static String getVersion() {
        String version = configuration.getProperty("siashan.unipay4j.wx.config.version");
        return version;
    }


    public static String getV3Key(){
        String v3Key = configuration.getProperty("siashan.unipay4j.wx.config.v3Key");
        return v3Key;
    }
    /**
     * 获取 证书序列号
     *
     * @return  证书序列号
     */
    public static String getMerchantSerialNumber() {
        String merchantSerialNumber = configuration.getProperty("siashan.unipay4j.wx.config.merchantSerialNumber");
        return merchantSerialNumber;
    }

    /**
     * 获取 商户私钥证书存放路径
     *
     * @return  商户私钥证书存放路径
     */
    public static String getMerchantPrivateKeyPath() {
        String merchantPrivateKeyPath = configuration.getProperty("siashan.unipay4j.wx.config.merchantPrivateKeyPath");
        return merchantPrivateKeyPath;
    }

}
